package com.project.service;

import com.project.bean.UserBean;
import com.project.dao.IUserDao;
import com.project.dao.impl.UserDaoImpl;
import com.project.server.Request;
import com.project.server.Response;
import com.project.server.Servlet;

public class FindByIdService implements Servlet {

    private IUserDao userDao = new UserDaoImpl();

    public void service(Request request, Response response) {
        int id = Integer.parseInt(request.getParameter("id"));

        UserBean user = userDao.findById(id);
        String str = "<form action= 'update'> " +
                //hidden隐藏表单
                "<input type='hidden' name='id' value='"+id+"'></br>" +
                "姓名：" + user.getUserName() + "</br>" +
                "密码：" + user.getPwd() + "</br>" +
                "生日：" + user.getBirthday() + "</br>" +
                "电话：<input type='text' name='phone' value ='" + user.getPhone() + "'></br>" +
                " <input type='submit' value='修改' ></form>";

        response.sendMessage(str);

    }
}
